﻿<UserControl x:Class="TimeSeriesFramework.UI.UserControls.MeasurementPagerUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             xmlns:uc="clr-namespace:TimeSeriesFramework.UI.UserControls"
             xmlns:tsfBinding="clr-namespace:TimeSeriesFramework.UI.Binding;assembly=TimeSeriesFramework.UI"
             d:DesignHeight="300" d:DesignWidth="500" Name="MeasurementPager" Loaded="MeasurementPager_Loaded">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/TimeSeriesFramework.UI.WPF;Component/Resources/CommonResource.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>

    <StackPanel Name="RootPanel" Orientation="Vertical">
        <DockPanel>
            <Label DockPanel.Dock="Left" Name="SelectedMeasurementsLabel" Content="Selected: 0" Visibility="{Binding ElementName=MeasurementPager, Path=Selectable, Converter={StaticResource ObjectToVisibilityConverter}}" />
        
            <StackPanel DockPanel.Dock="Right" Orientation="Horizontal" HorizontalAlignment="Right" Visibility="{Binding ElementName=MeasurementPager, Path=Searchable, Converter={StaticResource ObjectToVisibilityConverter}}">
                <TextBox x:Name="TextBoxSearch" Width="150"/>
                <Button Content="Search" Command="{Binding Path=SearchCommand}" CommandParameter="{Binding ElementName=TextBoxSearch, Path=Text}" ToolTip="Search measurements" Margin="2" IsDefault="True"/>
                <Button Content="Show All" Command="{Binding Path=ShowAllCommand}" ToolTip="Show all measurements" Margin="2"/>
            </StackPanel>
        </DockPanel>

        <Button Name="SelectAllHyperlink" Width="Auto" Content="Click here to select all measurements on all pages." HorizontalAlignment="Left" Visibility="Collapsed" Template="{StaticResource HyperlinkStyleButtonTemplate}" Click="SelectAllHyperlink_Click" Margin="0" />

        <DataGrid x:Name="DataGridList" ItemsSource="{Binding CurrentPage}" SelectedItem="{Binding Path=CurrentItem, Mode=TwoWay}" Height="Auto" Sorting="DataGrid_Sorting" IsReadOnly="True" LoadingRow="DataGridList_LoadingRow" SelectionMode="Single">
            <DataGrid.Columns>
                <DataGridTemplateColumn Width="50" Visibility="Collapsed">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox Name="ItemCheckBox" HorizontalAlignment="Center" Margin="0" Click="ItemCheckBox_Click" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.HeaderTemplate>
                        <DataTemplate>
                            <CheckBox Name="SelectAllCheckBox" Click="SelectAllCheckBox_Click" />
                        </DataTemplate>
                    </DataGridTemplateColumn.HeaderTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn Width="*" Header="Point Tag" Binding="{Binding PointTag}" />
                <DataGridTextColumn Width="*" Header="ID" Binding="{Binding ID}"/>
            </DataGrid.Columns>
        </DataGrid>

        <uc:DataPagerUserControl x:Name="DataPager" CurrentPageNumber="{Binding CurrentPageNumber}" PageCount="{Binding PageCount}"
                                 FirstCommand="{Binding FirstCommand}" PreviousCommand="{Binding PreviousCommand}"
                                 NextCommand="{Binding NextCommand}" LastCommand="{Binding LastCommand}"/>
    </StackPanel>
</UserControl>
